package bobaini.com.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * ClassName: RabbitMqUtils
 * author: bob.ly
 * Version: 1.0.0
 * DateTime: 2021/07/07-22:26:00
 * Description:链接工具类
 */
public class RabbitMqUtils {
    public static Channel getChannel() throws Exception {
        /**
         * 创建链接,得到一个信道
         */
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);
        factory.setUsername("guest");
        factory.setPassword("guest");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        return channel;
    }
}